<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/restrict/adminHome.xhtml">
	<f:metadata>
		<f:viewParam name="album" value="#{albumManagedBean.album}" converter="albumConversor" />
	</f:metadata>
	
	<ui:define name="titulo">
		<h:outputLabel value="MusicBay.com - #{msg.editar} #{msg.album}"/>
	</ui:define>

	<ui:define name="cont">
		<p:messages />
		<p:panel header="#{msg.editar} #{msg.album}">
			<h:form id="form">
				<h:inputHidden value="#{albumManagedBean.album.idAlbum}" />

				<h:panelGrid columns="3" cellpadding="7">
					<h:outputLabel value="#{msg.album}" for="nome" class="label" />
					<h:panelGroup>
						<p:inputText value="#{albumManagedBean.album.nome}" id="nome" label="#{msg.nome}" required="true"
							size="30" maxlength="30" requiredMessage="#{msg.nome} #{msg.naoInformado}">
							<f:validateLength minimum="2" maximum="30" />
						</p:inputText>
					</h:panelGroup>
					<p:message for="nome" />

					<h:outputLabel value="#{msg.ano}" for="ano" class="label" />
					<h:panelGroup>
						<p:inputText value="#{albumManagedBean.album.ano}" id="ano" label="#{msg.ano}" required="true"
							size="5" maxlength="4" requiredMessage="#{msg.ano} #{msg.naoInformado}">
							<f:validateLength minimum="4" maximum="4" />
						</p:inputText>
					</h:panelGroup>
					<p:message for="ano" />

					<h:outputLabel value="#{msg.artista}" for="artista" class="label" />
					<h:panelGroup>
						<p:selectOneMenu value="#{albumManagedBean.album.artista}" id="artista" required="true"
							requiredMessage="#{msg.artista} #{msg.naoInformado}" effect="fade" converter="artistaConversor">
							<f:selectItems value="#{artistaManagedBean.listaArtistas}" var="artista"
								itemLabel="#{artista.nome}" itemValue="#{artista}" />
						</p:selectOneMenu>
					</h:panelGroup>
					<p:message for="artista" />

					<h:outputLabel value="#{msg.status}" for="status" class="label" />
					<h:panelGroup styleClass="checkBox">
						<p:selectOneRadio id="status" value="#{albumManagedBean.album.status}" required="true">
							<f:selectItem itemLabel="#{msg.ativo}" itemValue="1" />
							<f:selectItem itemLabel="#{msg.inativo}" itemValue="0" />
						</p:selectOneRadio>
					</h:panelGroup>
					<p:message for="status" />

					<h:outputLabel value="#{msg.imagem}" class="label"/>
					<h:form enctype="multipart/form-data">
						<p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}" mode="advanced"
							update="messages" multiple="false" allowTypes="/(\.|\/)(gif|jpe?g|png|JGP)$/"
							styleClass="upload" auto="true">												
						</p:fileUpload>
						<p:growl id="messages" showDetail="true" />
					</h:form>
					<h:outputLabel value="" />

					<p:commandButton id="showcadastroDialog" value="#{msg.concluir} #{msg.edicao}" oncomplete="editDialog.show()"/>					
					<p:commandButton id="cancel" value="#{msg.cancelar} #{msg.edicao}" action="listaAlbum" ajax="false" />

				</h:panelGrid>

				<p:confirmDialog id="editDialog" message="#{msg.concluir} #{msg.edicao}?" header="#{msg.editar} #{msg.album}?"
					severity="alert" widgetVar="editDialog">

					<p:commandButton id="confirmar" value="#{msg.confirma}" ajax="false"
						actionListener="#{albumManagedBean.actionUpdate}" oncomplete="editDialog.hide()">
						<f:attribute name="img" value="#{fileUploadController.by}"/>																																									
					</p:commandButton>
					<p:commandButton id="cancela" value="#{msg.cancelar}" onclick="editDialog.hide()" type="button" />
				</p:confirmDialog>
			</h:form>
		</p:panel>
	</ui:define>
</ui:composition>
</html>